import {ref} from "vue";
export default function useBuildTreeSelectOptions() {
    const treeSelectOptions = ref()
    function buildTreeSelectOptions(data: any,idKey: string,labelKey: string) {
        function build(arr: any[]){
            arr.forEach(d=>{
                d.id = d[idKey]
                d.label = d[labelKey]
                if(d.children){
                    build(d.children)
                }
            })
        }
        build(data)
        treeSelectOptions.value = data
    }
    return {
        buildTreeSelectOptions,
        treeSelectOptions
    }
}
